package lab1;

public class EulerMethod {

    public static void main(String[] args) {
        System.out.println("Varianta 2 Euler : h = 0.1 n = 10" );
        eulerMethod(1,1,0.1,10);
        System.out.println("Varianta 2 Euler : h = 0.2 n = 10" );
        eulerMethod(1,1,0.2,10);
    }

    private static void eulerMethod(double x0, double u0, final double h, final int n){
        double newU=0;
        for (int i = 0; i <= n; i++) {
            newU=u0 + h * (-3 * u0 * u0*x0*x0);
            System.out.println("New U: " + newU);
            x0=x0+h;
            u0 = newU;
        }
    }
}
